package com.beiming.moudle.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.beiming.moudle.auth.dao.CustomerDao;
import com.beiming.moudle.auth.entity.BussEntity;
import com.beiming.moudle.auth.entity.CustomerEntity;
import com.beiming.moudle.auth.entity.ProductInfoEntity;
import com.beiming.moudle.auth.entity.utillClass.CustomerPage;
import com.beiming.moudle.auth.entity.utillClass.ProInfoPage;
import com.beiming.moudle.auth.service.CustomerService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity> implements CustomerService {

    @Autowired
    private CustomerDao customerDao;
    @Override
    public String getCustmoerName(int id) {
        QueryWrapper<CustomerEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("customer_inf_id",id);
        CustomerEntity customerEntity=  customerDao.selectOne(queryWrapper);
        return customerEntity.getCustomerName();
    }
    public IPage<CustomerEntity> getMsgPage(CustomerPage customerPage) {
        LambdaQueryWrapper<CustomerEntity> lqw = new LambdaQueryWrapper<>();
        lqw.like(Strings.isNotEmpty(customerPage.getCustomerCode()),CustomerEntity::getCustomerCode,customerPage.getCustomerCode());
        IPage pag = new Page(customerPage.getCurrentPage(),customerPage.getPageSize());
        customerDao.selectPage(pag,lqw);
        return pag;
    }

}
